﻿using System.Windows.Controls;
using PrismForWpfSample.Views;

namespace PrismForWpfSample.ViewModels
{
    public class MainWindowViewModel: BindableBase
    {
		private readonly IRegionManager _regionManager;

        private readonly IDialogService _dialogService;

		public MainWindowViewModel(IRegionManager regionManager, IDialogService dialogService) {
			_regionManager = regionManager;
            _dialogService = dialogService;
            ChangeRegionCommand = new DelegateCommand<string>(changeRegion);
            OpenDialogCommand = new DelegateCommand<string>(openDialog);
        }

		private void changeRegion(string name) 
        {
           
            var param = new NavigationParameters
            {
                { "title", "hhh 我是：" + name }
            };
            _regionManager.Regions["ContentRegion"].RequestNavigate(name, param);
        }

        private void openDialog(string name) 
        {
            _dialogService.ShowDialog(name);
        }

        public DelegateCommand<string> ChangeRegionCommand { get; private set; }

        public DelegateCommand<string> OpenDialogCommand { get; private set; }

	}
}
